package com.tebiecloud.api.gateway.server;

import com.tebiecloud.api.gateway.server.locator.ApiResourceLocator;
import com.tebiecloud.api.gateway.server.locator.JdbcRouteDefinitionLocator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.bus.jackson.RemoteApplicationEventScan;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;

/**
 * 网关服务
 * 接口调用统一入口、数字验签、身份认证、接口鉴权、接口限流、黑白名单限制
 * @Author: tebie
 * @Date: 2019-08-08 16:05
 */
@EnableFeignClients
@EnableDiscoveryClient
@SpringBootApplication
@RemoteApplicationEventScan(basePackages = "com.tebiecloud")
public class ApiGatewayApplication implements CommandLineRunner {

    @Autowired
    public ApiResourceLocator apiResourceLocator;
    @Autowired
    private JdbcRouteDefinitionLocator jdbcRouteDefinitionLocator;

    public static void main(String[] args) {
        SpringApplication.run(ApiGatewayApplication.class, args);
    }

    @Override
    public void run(String... strings) throws Exception {
        jdbcRouteDefinitionLocator.refresh();
        apiResourceLocator.refresh();
    }

}
